<template>
  <div class="app-container">
    <!-- 查询对话框   -->
    <el-dialog
      :title="title"
      v-model="openSearch"
      :close-on-click-modal="false"
      draggable
      width="780px"
      append-to-body
    >
      <el-form
        :model="queryParams"
        ref="queryForm"
        :inline="true"
        label-width="98px"
      >
        <el-col :span="12">
          <el-form-item label="过账入库日期">
            <el-date-picker
              v-model="dateRange"
              clearable
              size="small"
              type="daterange"
              style="width: 240px"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :clearable="false"
              :picker-options="pickerOptions"
              :default-time="['00:00:00', '23:59:59']"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="PDA入库日期">
            <el-date-picker
              v-model="dateRange1"
              clearable
              size="small"
              type="daterange"
              style="width: 240px"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :picker-options="pickerOptions"
              :default-time="['00:00:00', '23:59:59']"
            ></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="入库单号" prop="djbh">
            <el-input
              v-model="queryParams.djbh"
              placeholder="请输入入库单号"
              clearable
              style="width: 240px"
              size="small"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="制造单号" prop="zzdh">
            <el-input
              v-model="queryParams.zzdh"
              placeholder="请输入制造单号"
              clearable
              style="width: 240px"
              size="small"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="物料代码" prop="wldm">
            <el-input
              v-model="queryParams.wldm"
              placeholder="请输入物料代码"
              clearable
              style="width: 240px"
              size="small"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="入库仓库" prop="ckdm">
            <el-select
              v-model="queryParams.ckdm"
              style="width: 240px"
              clearable
              placeholder="请选择入库仓库"
            >
              <el-option
                v-for="item in storageOptions"
                :key="item.dictValue"
                :label="item.dictLabel"
                :value="item.dictValue"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="综合查询" prop="pmgg">
            <el-input
              type="textarea"
              style="width: 550px"
              v-model="queryParams.pmgg"
              placeholder="请输入综合查询"
              clearable
              size="small"
            />
          </el-form-item>
        </el-col>

        <el-col :span="24">
          <el-form-item prop="ztbz" style="padding-left: 95px">
            <RadioGroup v-model="queryParams.ztbz">
              <Radio label="1">未过账</Radio>
              <Radio label="2">已过账</Radio>
              <Radio label="">全部</Radio>
            </RadioGroup>
          </el-form-item>
        </el-col>

        <el-col :span="24">
          <el-form-item
            style="margin-top: 25px; display: flex; justify-content: flex-end"
          >
            <el-button @click="cancel">取消</el-button>
            <el-button type="primary" @click="handleQuery">确认</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-dialog>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-search"
          @click="handleSearch"
          size="small"
          >查询</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          v-hasPermi="['putStorage:halfFinish:export']"
          @click="handleExcel(1)"
          size="small"
        >
          明细数据
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          v-hasPermi="['putStorage:halfFinish:export']"
          @click="handleExcel(2)"
          size="small"
        >
          物料统计
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          v-hasPermi="['putStorage:halfFinish:export']"
          @click="handleExcel(3)"
          size="small"
        >
          日期统计
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          v-hasPermi="['putStorage:halfFinish:export']"
          @click="handleExcel(4)"
          size="small"
        >
          仓库统计
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          v-hasPermi="['putStorage:halfFinish:export']"
          @click="handleExcel(5)"
          size="small"
        >
          成品入库
        </el-button>
      </el-col>
    </el-row>
    <el-tabs v-model="activeTab">
      <el-tab-pane label="明细数据" name="first">
        <el-table
          :cell-style="styleCell"
          border
          stripe
          id="exportGdMx"
          :height="tableH"
          @scrollBottom="load1"
          :data="rpdDetList"
          :header-cell-style="{ 'text-align': 'center' }"
        >
          <el-table-column
            label="#"
            type="index"
            width="55"
            align="center"
            fixed="left"
          />
          <el-table-column
            label="入库单号"
            align="center"
            width="135"
            show-overflow-tooltip
            prop="rpdDjbh"
          />
          <el-table-column
            label="客户编码"
            align="center"
            width="135"
            show-overflow-tooltip
            prop="itmCustwldm"
          />
          <el-table-column
            label="物料代码"
            align="center"
            width="135"
            show-overflow-tooltip
            prop="rpdWldm"
          />
          <el-table-column
            label="品名规格"
            prop="itmPmgg"
            show-overflow-tooltip
            width="400"
          />
          <el-table-column
            label="申请数量"
            prop="rpdSqsl"
            align="center"
            width="100"
          />
          <el-table-column
            label="允收数量"
            prop="rpdOksl"
            align="center"
            width="100"
          />
          <el-table-column
            label="拒收数量"
            prop="rpdNgsl"
            align="center"
            width="100"
          />
          <el-table-column
            label="入库数量"
            prop="rpdRksl"
            align="center"
            width="100"
          />
          <el-table-column
            label="仓库"
            :show-overflow-tooltip="true"
            width="140"
            align="center"
            prop="rpmCkdm"
          >
            <template #default="scope">
              <dict-tag
                :options="allStorageOptions"
                :value="scope.row.rpmCkdm"
              />
            </template>
          </el-table-column>
          <el-table-column
            label="班别"
            prop="rpmBcdm"
            align="center"
            :show-overflow-tooltip="true"
            width="100"
          />
          <el-table-column
            label="制造单号"
            prop="rpdZzdh"
            :show-overflow-tooltip="true"
            align="center"
            width="135"
          />
          <el-table-column
            label="机台"
            prop="rpdJtbh"
            align="center"
            :show-overflow-tooltip="true"
            width="100"
          />
          <el-table-column
            label="单位"
            :show-overflow-tooltip="true"
            width="60"
            align="center"
            prop="itm_dw"
          >
            <template #default="scope">
              <dict-tag :options="unitFlagOptions" :value="scope.row.itmDw" />
            </template>
          </el-table-column>
          <el-table-column label="箱包装数" prop="rpdMxsl" width="100" />
          <el-table-column label="入库备注" prop="rpdDesc" width="100" />
          <el-table-column
            label="检验结果"
            :show-overflow-tooltip="true"
            width="100"
            align="center"
            prop="rpdJyjg"
          >
            <template #default="scope">
              <dict-tag :options="jyjgDict" :value="scope.row.rpdJyjg" />
            </template>
          </el-table-column>
          <el-table-column label="检验描述" prop="rpdJyms" width="100" />
          <el-table-column
            label="备注"
            prop="rpmDesc"
            :show-overflow-tooltip="true"
            width="250"
          />
          <el-table-column
            label="开单人员"
            prop="rpmJlry"
            align="center"
            width="100"
          />
          <el-table-column
            label="开单日期"
            :show-overflow-tooltip="true"
            width="150"
            align="center"
            prop="rpmJlrq"
          >
            <template #default="scope">
              <span>{{
                parseTime(scope.row.rpmJlrq, "{y}-{m}-{d} {h}:{i}:{s}")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="检验人员"
            prop="rpmJyry"
            align="center"
            width="100"
          />
          <el-table-column
            label="检验日期"
            :show-overflow-tooltip="true"
            width="150"
            align="center"
            prop="rpmJyrq"
          >
            <template #default="scope">
              <span>{{
                parseTime(scope.row.rpmJyrq, "{y}-{m}-{d} {h}:{i}:{s}")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="入库人员"
            prop="rpdRkry"
            align="center"
            width="100"
          />
          <el-table-column
            label="入库日期"
            :show-overflow-tooltip="true"
            width="150"
            align="center"
            prop="rpdRkrq"
          >
            <template #default="scope">
              <span>{{
                parseTime(scope.row.rpdRkrq, "{y}-{m}-{d} {h}:{i}:{s}")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="PDA入库日期"
            :show-overflow-tooltip="true"
            width="150"
            align="center"
            prop="rpdRkDate"
          >
            <template #default="scope">
              <span>{{
                parseTime(scope.row.rpdRkDate, "{y}-{m}-{d} {h}:{i}:{s}")
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="过账人员"
            prop="rpmGzry"
            align="center"
            width="100"
          />
          <el-table-column
            label="过账日期"
            :show-overflow-tooltip="true"
            width="150"
            align="center"
            prop="rpmGzrq"
          >
            <template #default="scope">
              <span>{{
                parseTime(scope.row.rpmGzrq, "{y}-{m}-{d} {h}:{i}:{s}")
              }}</span>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="按物料统计" name="three">
        <el-table
          :cell-style="styleCell"
          border
          stripe
          :height="tableH"
          id="exportGdTotal"
          @scrollBottom="load2"
          :data="rpdWldmTotal"
          :header-cell-style="{ 'text-align': 'center' }"
        >
          <el-table-column
            label="#"
            type="index"
            width="55"
            align="center"
            fixed="left"
          />
          <el-table-column
            label="客户编码"
            align="center"
            width="135"
            prop="itmCustwldm"
          />
          <el-table-column
            label="物料代码"
            align="center"
            width="135"
            prop="rpdWldm"
          />
          <el-table-column
            label="入库单号"
            align="center"
            width="135"
            prop="rpdDjbh"
          />
          <el-table-column
            label="品名规格"
            align="center"
            prop="itmPmgg"
            width="400"
          />
          <el-table-column
            label="单位"
            :show-overflow-tooltip="true"
            width="60"
            align="center"
            prop="itmDw"
          >
            <template #default="scope">
              <dict-tag :options="unitFlagOptions" :value="scope.row.itmDw" />
            </template>
          </el-table-column>
          <el-table-column label="申请数量" prop="rpdSqsl" width="100" />
          <el-table-column label="允收数量" prop="rpdOksl" width="100" />
          <el-table-column label="拒收数量" prop="rpdNgsl" width="100" />
          <el-table-column label="入库数量" prop="rpdRksl" width="100" />
          <el-table-column label="过账日期" prop="rpmGzrq" width="100" />
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="按日期统计" name="four">
        <el-table
          :cell-style="styleCell"
          border
          stripe
          :height="tableH"
          id="exportGdData"
          @scrollBottom="load3"
          :data="rpdCkdmTotal"
          :header-cell-style="{ 'text-align': 'center' }"
        >
          <el-table-column
            label="#"
            type="index"
            width="55"
            align="center"
            fixed="left"
          />
          <el-table-column label="过账日期" prop="rpmGzrq" width="100" />
          <el-table-column
            label="客户编码"
            align="center"
            width="135"
            prop="itmCustwldm"
          />
          <el-table-column
            label="物料代码"
            align="center"
            width="135"
            prop="rpdWldm"
          />
          <el-table-column
            label="品名规格"
            align="center"
            prop="itmPmgg"
            width="135"
          />
          <el-table-column
            label="单位"
            :show-overflow-tooltip="true"
            width="60"
            align="center"
            prop="itmDw"
          >
            <template #default="scope">
              <dict-tag :options="unitFlagOptions" :value="scope.row.itmDw" />
            </template>
          </el-table-column>
          <el-table-column label="申请数量" prop="rpdSqsl" width="100" />
          <el-table-column label="允收数量" prop="rpdOksl" width="100" />
          <el-table-column label="拒收数量" prop="rpdNgsl" width="100" />
          <el-table-column label="入库数量" prop="rpdRksl" width="100" />
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="按仓库统计" name="five">
        <el-table
          :cell-style="styleCell"
          border
          stripe
          :height="tableH"
          id="exportGdCustom"
          @scrollBottom="load4"
          :data="rpdDateTotal"
          :header-cell-style="{ 'text-align': 'center' }"
        >
          <el-table-column
            label="#"
            type="index"
            width="55"
            align="center"
            fixed="left"
          />
          <el-table-column
            label="仓库"
            :show-overflow-tooltip="true"
            width="140"
            align="center"
            prop="rpmCkdm"
          >
            <template #default="scope">
              <dict-tag
                :options="allStorageOptions"
                :value="scope.row.rpmCkdm"
              />
            </template>
          </el-table-column>
          <el-table-column
            label="客户编码"
            align="center"
            width="135"
            prop="itmCustwldm"
          />
          <el-table-column
            label="物料代码"
            align="center"
            width="135"
            prop="rpdWldm"
          />
          <el-table-column
            label="品名规格"
            align="center"
            prop="itmPmgg"
            width="135"
          />
          <el-table-column
            label="单位"
            :show-overflow-tooltip="true"
            width="60"
            align="center"
            prop="itmDw"
          >
            <template #default="scope">
              <dict-tag :options="unitFlagOptions" :value="scope.row.itmDw" />
            </template>
          </el-table-column>
          <el-table-column label="申请数量" prop="rpdSqsl" width="100" />
          <el-table-column label="允收数量" prop="rpdOksl" width="100" />
          <el-table-column label="拒收数量" prop="rpdNgsl" width="100" />
          <el-table-column label="入库数量" prop="rpdRksl" width="100" />
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="成品入库单" name="six">
        <el-table
          :cell-style="styleCell"
          border
          stripe
          :height="tableH"
          id="exportGdHalf"
          @scrollBottom="load5"
          :data="rpdRkDjbh"
          :header-cell-style="{ 'text-align': 'center' }"
        >
          <el-table-column
            label="#"
            type="index"
            width="55"
            align="center"
            fixed="left"
          />
          <el-table-column
            label="客户编码"
            align="center"
            width="135"
            prop="itmCustwldm"
          />
          <el-table-column label="制造单号" prop="rpdZzdh" width="100" />
          <el-table-column label="产品名称" prop="rpdWldm" width="100" />
          <el-table-column
            label="物料编码"
            align="center"
            width="135"
            prop="itmPmgg"
          />
          <el-table-column
            label="单位"
            :show-overflow-tooltip="true"
            width="60"
            align="center"
            prop="itmDw"
          >
            <template #default="scope">
              <dict-tag :options="unitFlagOptions" :value="scope.row.itmDw" />
            </template>
          </el-table-column>
          <el-table-column label="申请数量" prop="rpdSqsl" width="100" />
          <el-table-column label="允收数量" prop="rpdOksl" width="100" />
          <el-table-column label="拒收数量" prop="rpdNgsl" width="100" />
          <el-table-column label="入库数量" prop="rpdRksl" width="100" />
          <el-table-column
            label="仓库"
            :show-overflow-tooltip="true"
            width="140"
            align="center"
            prop="rpmCkdm"
          >
            <template #default="scope">
              <dict-tag
                :options="allStorageOptions"
                :value="scope.row.rpmCkdm"
              />
            </template>
          </el-table-column>
          <el-table-column
            label="日期"
            :show-overflow-tooltip="true"
            width="150"
            align="center"
            prop="rpmGzrq"
          >
            <template #default="scope">
              <span>{{
                parseTime(scope.row.rpmGzrq, "{y}-{m}-{d} {h}:{i}:{s}")
              }}</span>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import { getAll, getstorageType } from "@/api/repertory/Storage";
import { exportTable } from "@/utils/ruoyi";
import { exportRpmReport, rpmReportList } from "@/api/putStorage/RpmMstr";
import { exportRzm } from "@/api/production/rzm";
import { exportChmReport } from "@/api/output/proShipped";

export default {
  name: "RpmReport",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 非单个禁用
      tableH: document.body.clientHeight - 300,
      activeTab: "first",
      // 非多个禁用
      rpdDetList: [],
      rpdDateTotal: [],
      rpdWldmTotal: [],
      rpdCkdmTotal: [],
      rpdRkDjbh: [],
      // 显示搜索条件
      openSearch: false,
      // 总条数
      total1: 0,
      total2: 0,
      total3: 0,
      total4: 0,
      total5: 0,

      //有效存储仓库
      storageOptions: [],
      jyjgDict: [
        { dictLabel: "允收", dictValue: "OK", listClass: "default" },
        { dictLabel: "拒收", dictValue: "NG", listClass: "default" },
        { dictLabel: "特采", dictValue: "TC", listClass: "default" },
      ],
      //所有存储仓库
      allStorageOptions: [],
      // 弹出层标题
      title: "",
      // 建立日期时间范围
      dateRange: [
        this.moment("0:0:0", "H:m:s").add(-30, "days"),
        this.moment("23:59:59", "H:m:s").add(60, "days"),
      ],
      dateRange1: [undefined, undefined],
      unitFlagOptions: [],
      type1: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 30,
        djbh: null,
        zzdh: null,
        wldm: null,
        ckdm: null,
        pmgg: null,
        ztbz: "",
      },

      // 表单参数
      form: {},
      // 表单校验
      //日期初始化
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
    };
  },
  created() {
    this.getList();
    //单位
    this.getDicts("sys_unit").then((response) => {
      this.unitFlagOptions = response.data;
    });

    getAll().then((response) => {
      this.allStorageOptions = response.data;
      for (let item of this.allStorageOptions) {
        item.dictLabel = item.storageName;
        item.listClass = "default";
        item.dictValue = item.storageId + "";
      }
    });

    getstorageType("0").then((response) => {
      this.storageOptions = response.data;

      for (let item of this.storageOptions) {
        item.dictLabel = item.storageName;
        item.listClass = "default";
        item.dictValue = item.storageId + "";
      }
    });
  },
  methods: {
    /** 查询来料进货入库开单列表 */
    getList() {
      this.loading = true;
      this.queryParams.rkrq = {};
      if (null != this.dateRange && "" != this.dateRange) {
        this.queryParams.rkrq["begin"] = this.moment(this.dateRange[0]).format(
          "YYYY-MM-DD HH:mm:ss"
        );
        this.queryParams.rkrq["end"] = this.moment(this.dateRange[1]).format(
          "YYYY-MM-DD HH:mm:ss"
        );
      }
      if (this.dateRange1 && this.dateRange1[0]) {
        this.queryParams.rkrq["beginPDA"] = this.moment(
          this.dateRange1[0]
        ).format("YYYY-MM-DD HH:mm:ss");
        this.queryParams.rkrq["endPDA"] = this.moment(
          this.dateRange1[1]
        ).format("YYYY-MM-DD HH:mm:ss");
      }
      this.queryParams.pageNum = 1;
      return rpmReportList(this.queryParams).then((response) => {
        //明细
        this.rpdDetList = [];
        this.rpdDetList = this.rpdDetList.concat(response.data.list1.rows);

        //物料统计
        this.rpdWldmTotal = [];
        this.rpdWldmTotal = this.rpdWldmTotal.concat(response.data.list2.rows);

        //日期统计
        this.rpdDateTotal = [];
        this.rpdDateTotal = this.rpdDateTotal.concat(response.data.list4.rows);

        //仓库统计
        this.rpdCkdmTotal = [];
        this.rpdCkdmTotal = this.rpdCkdmTotal.concat(response.data.list3.rows);

        // 入库单
        this.rpdRkDjbh = [];
        this.rpdRkDjbh = this.rpdRkDjbh.concat(response.data.list5.rows);

        this.total1 = response.data.list1.total;
        this.total2 = response.data.list2.total;
        this.total3 = response.data.list3.total;
        this.total4 = response.data.list4.total;
        this.total5 = response.data.list5.total;
        console.log(
          this.total1 +
            "/1" +
            this.total2 +
            "/2" +
            this.total3 +
            "/3" +
            this.total4 +
            "/4" +
            this.total5 +
            "/5"
        );
        this.loading = false;
      });
    },
    load1() {
      if (
        this.queryParams.pageNum <
        Math.ceil(this.total1 / this.queryParams.pageSize)
      ) {
        this.queryParams.pageNum++;
        rpmReportList(this.queryParams).then((response) => {
          this.rpdDetList = this.rpdDetList.concat(response.data.list1.rows);
          this.total1 = response.data.list1.total;

          this.loading = false;
        });
      }
      return 0;
    },
    load2() {
      if (
        this.queryParams.pageNum <
        Math.ceil(this.total2 / this.queryParams.pageSize)
      ) {
        this.queryParams.pageNum++;
        rpmReportList(this.queryParams).then((response) => {
          this.rpdWldmTotal = this.rpdWldmTotal.concat(
            response.data.list2.rows
          );
          this.total2 = response.data.list2.total;

          this.loading = false;
        });
      }
      return 0;
    },
    load3() {
      if (
        this.queryParams.pageNum <
        Math.ceil(this.total3 / this.queryParams.pageSize)
      ) {
        this.queryParams.pageNum++;
        rpmReportList(this.queryParams).then((response) => {
          this.rpdCkdmTotal = this.rpdCkdmTotal.concat(
            response.data.list3.rows
          );
          this.total3 = response.data.list3.total;

          this.loading = false;
        });
      }
      return 0;
    },
    load4() {
      if (
        this.queryParams.pageNum <
        Math.ceil(this.total4 / this.queryParams.pageSize)
      ) {
        this.queryParams.pageNum++;
        rpmReportList(this.queryParams).then((response) => {
          this.rpdDateTotal = this.rpdDateTotal.concat(
            response.data.list4.rows
          );
          this.total4 = response.data.list4.total;

          this.loading = false;
        });
      }
      return 0;
    },

    load5() {
      if (
        this.queryParams.pageNum <
        Math.ceil(this.total5 / this.queryParams.pageSize)
      ) {
        this.queryParams.pageNum++;
        rpmReportList(this.queryParams).then((response) => {
          this.rpdRkDjbh = this.rpdRkDjbh.concat(response.data.list5.rows);
          this.total5 = response.data.list5.total;

          this.loading = false;
        });
      }
      return 0;
    },

    handleDc(a, b, e) {
      /*      if (this.queryParams.pageSize !== 9999) {
        this.queryParams.pageSize = 9999
        this.getList().then(() => {
          this.$nextTick(() => {
            exportTable(a, b)
          })
        })
      } else {
        exportTable(a, b)
      }*/
      const queryParams = this.queryParams;
      this.$confirm("是否确认导出所有成品/半成品报表?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.exportLoading = true;
          return exportRpmReport(queryParams);
        })
        .then((response) => {
          this.download(response.msg);
          this.exportLoading = false;
        })
        .catch(() => {});
    },
    handleSearch() {
      this.openSearch = true;
      this.title = "查询来料进货统计分析";
    },
    // 取消按钮
    cancel() {
      this.openSearch = false;
      this.reset();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
      this.openSearch = false;
    },
    styleCell({ row, column, rowIndex, columnIndex }) {
      if (row[column.property] && row[column.property] < 0)
        return { color: "red" };
    },
    //导出Excel
    handleExcel(index) {
      this.queryParams.index = index;
      const queryParams = this.queryParams;
      exportRpmReport(queryParams).then((response) => {
        this.download(response.msg);
        this.queryParams.index = 0;
      });
    },
  },
};
</script>

<style scoped></style>
